package com.prs.crm.action.cdxh;

import java.util.Collection;
import java.util.Date;
import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.annotation.Clew;
import com.prs.crm.domain.cdxh.material.MaterialPrint;
import com.prs.crm.domain.cdxh.material.MaterialPrintDetail;
import com.prs.crm.domain.cdxh.material.MaterialTeam;
import com.prs.crm.service.cdxh.MaterialPrintService;
import com.prs.crm.service.cdxh.MaterialTeamService;

/**
 * @author LanXiaoGang
 * @E-mail:lan9liang@163.com
 * @qq:7857553326
 * @version 创建时间：2010-12-6 上午10:44:59 简单说明
 */
public class MaterialTeamAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	private PaginationSupport pagination;

	private MaterialPrint materialPrint;

	private MaterialPrintService materialPrintService;

	private MaterialTeam materialTeam;

	private MaterialTeamService materialTeamService;

	/**
	 * 配料对应产品属性
	 * 
	 * @return
	 */
	private String[] materialYanse;
	private String[] materialNorm;
	private String[] materialTanca;
	private String[] materialPvc;
	private String[] materialScal;
	private String[] materialDop;
	private String[] materialProductNum;
	private String[] materialSjProNum;
	private String[] materialSyWuLiao;
	private String[] materialCustomer;
	private String[] materialFeiLiao;
	private String[] materialStopState;
	private String[] materialSuDu;
	private String[] materialRemark;
	private Date[] supplierDate;
	private String[] rushOrder;

	private String[] productNums;
	private Integer[] idObject;
	private String[] planOrOrderId;
	private String[] productCodes;
	private String[] productPackstyle;
	private Integer[] backProductSate;

	private Collection<MaterialPrintDetail> slist;

	@Clew(results = { "success", "none", "error" })
	@Action(value = "saveMaterialProduct", results = {
			@Result(name = "success", type = "redirect", location = "listMaterialProduct"),
			@Result(name = "error", type = "redirect", location = "listMaterialProduct") })
	public String saveMaterialProduct() {
		this.getMaterialTeamService().saveMaterialTeam(materialTeam,
				materialYanse, materialNorm, materialTanca, materialPvc,
				materialScal, materialDop, materialProductNum,
				materialSjProNum, materialSyWuLiao, materialCustomer,
				materialFeiLiao, materialStopState, materialSuDu,
				materialRemark, productNums, idObject, planOrOrderId,
				supplierDate, rushOrder, productCodes, productPackstyle,
				backProductSate);
		this.setPrompt("该配料单创建成功!");
		return SUCCESS;
	}

	@Clew(results = { "success", "none", "error" })
	@Action(value = "saveMaterialPrint", results = {
			@Result(name = "success", type = "redirect", location = "listMaterialProduct"),
			@Result(name = "error", type = "redirect", location = "listMaterialProduct") })
	public String saveMaterialPrint() {
		this.getMaterialTeamService().saveMaterialTeamPrint(materialTeam,
				materialYanse, materialNorm, materialTanca, materialPvc,
				materialScal, materialDop, materialProductNum,
				materialSjProNum, materialSyWuLiao, materialCustomer,
				materialFeiLiao, materialStopState, materialSuDu,
				materialRemark, productNums, idObject, planOrOrderId,
				supplierDate, rushOrder, productCodes, productPackstyle,
				backProductSate);

		this.setPrompt("该配料单打印预览创建成功!");
		return SUCCESS;
	}

	@Action("listMaterialTeam")
	public String listMaterialTeam() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				MaterialTeam.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getMaterialTeamService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("listMaterialTeamPrint")
	public String listMaterialTeamPrint() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				MaterialPrint.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getMaterialPrintService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("viewMaterialTeamPrint")
	public String viewMaterialTeamPrint() {
		materialPrint = this.getMaterialPrintService().get(
				materialPrint.getId());
		slist = materialPrint.getDetails();
		return SUCCESS;
	}

	@Action("viewMarterialTeam")
	public String viewMarterialTeam() {
		materialTeam = this.getMaterialTeamService().get(materialTeam.getId());
		return SUCCESS;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public MaterialPrint getMaterialPrint() {
		return materialPrint;
	}

	public void setMaterialPrint(MaterialPrint materialPrint) {
		this.materialPrint = materialPrint;
	}

	public MaterialPrintService getMaterialPrintService() {
		return materialPrintService;
	}

	public void setMaterialPrintService(
			MaterialPrintService materialPrintService) {
		this.materialPrintService = materialPrintService;
	}

	public MaterialTeam getMaterialTeam() {
		return materialTeam;
	}

	public void setMaterialTeam(MaterialTeam materialTeam) {
		this.materialTeam = materialTeam;
	}

	public MaterialTeamService getMaterialTeamService() {
		return materialTeamService;
	}

	public void setMaterialTeamService(MaterialTeamService materialTeamService) {
		this.materialTeamService = materialTeamService;
	}

	public String[] getMaterialYanse() {
		return materialYanse;
	}

	public void setMaterialYanse(String[] materialYanse) {
		this.materialYanse = materialYanse;
	}

	public String[] getMaterialNorm() {
		return materialNorm;
	}

	public void setMaterialNorm(String[] materialNorm) {
		this.materialNorm = materialNorm;
	}

	public String[] getMaterialTanca() {
		return materialTanca;
	}

	public void setMaterialTanca(String[] materialTanca) {
		this.materialTanca = materialTanca;
	}

	public String[] getMaterialPvc() {
		return materialPvc;
	}

	public void setMaterialPvc(String[] materialPvc) {
		this.materialPvc = materialPvc;
	}

	public String[] getMaterialScal() {
		return materialScal;
	}

	public void setMaterialScal(String[] materialScal) {
		this.materialScal = materialScal;
	}

	public String[] getMaterialDop() {
		return materialDop;
	}

	public void setMaterialDop(String[] materialDop) {
		this.materialDop = materialDop;
	}

	public String[] getMaterialProductNum() {
		return materialProductNum;
	}

	public void setMaterialProductNum(String[] materialProductNum) {
		this.materialProductNum = materialProductNum;
	}

	public String[] getMaterialSjProNum() {
		return materialSjProNum;
	}

	public void setMaterialSjProNum(String[] materialSjProNum) {
		this.materialSjProNum = materialSjProNum;
	}

	public String[] getMaterialSyWuLiao() {
		return materialSyWuLiao;
	}

	public void setMaterialSyWuLiao(String[] materialSyWuLiao) {
		this.materialSyWuLiao = materialSyWuLiao;
	}

	public String[] getMaterialCustomer() {
		return materialCustomer;
	}

	public void setMaterialCustomer(String[] materialCustomer) {
		this.materialCustomer = materialCustomer;
	}

	public String[] getMaterialFeiLiao() {
		return materialFeiLiao;
	}

	public void setMaterialFeiLiao(String[] materialFeiLiao) {
		this.materialFeiLiao = materialFeiLiao;
	}

	public String[] getMaterialStopState() {
		return materialStopState;
	}

	public void setMaterialStopState(String[] materialStopState) {
		this.materialStopState = materialStopState;
	}

	public String[] getMaterialSuDu() {
		return materialSuDu;
	}

	public void setMaterialSuDu(String[] materialSuDu) {
		this.materialSuDu = materialSuDu;
	}

	public String[] getMaterialRemark() {
		return materialRemark;
	}

	public void setMaterialRemark(String[] materialRemark) {
		this.materialRemark = materialRemark;
	}

	public String[] getProductNums() {
		return productNums;
	}

	public void setProductNums(String[] productNums) {
		this.productNums = productNums;
	}

	public Integer[] getIdObject() {
		return idObject;
	}

	public void setIdObject(Integer[] idObject) {
		this.idObject = idObject;
	}

	public String[] getPlanOrOrderId() {
		return planOrOrderId;
	}

	public void setPlanOrOrderId(String[] planOrOrderId) {
		this.planOrOrderId = planOrOrderId;
	}

	public Date[] getSupplierDate() {
		return supplierDate;
	}

	public void setSupplierDate(Date[] supplierDate) {
		this.supplierDate = supplierDate;
	}

	public String[] getRushOrder() {
		return rushOrder;
	}

	public void setRushOrder(String[] rushOrder) {
		this.rushOrder = rushOrder;
	}

	public String[] getProductCodes() {
		return productCodes;
	}

	public void setProductCodes(String[] productCodes) {
		this.productCodes = productCodes;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String[] getProductPackstyle() {
		return productPackstyle;
	}

	public void setProductPackstyle(String[] productPackstyle) {
		this.productPackstyle = productPackstyle;
	}

	public Integer[] getBackProductSate() {
		return backProductSate;
	}

	public void setBackProductSate(Integer[] backProductSate) {
		this.backProductSate = backProductSate;
	}

	public Collection<MaterialPrintDetail> getSlist() {
		return slist;
	}

	public void setSlist(Collection<MaterialPrintDetail> slist) {
		this.slist = slist;
	}

}
